package com.sproutcat.sample.singleton;

/**
 * 单例模式（饿汉模式）
 *
 * @author tzg
 */
public class Singleton1 {

    private static final Singleton1 INSTANCE = new Singleton1();

    /**
     * 构造函数为 private
     */
    private Singleton1() {
    }

    public static Singleton1 getInstance() {
        return INSTANCE;
    }

    /**
     * 此处模拟类中处理业务的方法
     */
    public void m() {
        System.out.println("m");
    }

    public static void main(String[] args) {
        Singleton1 s1 = Singleton1.getInstance();
        Singleton1 s2 = Singleton1.getInstance();

        System.out.println(s1.equals(s2));
    }

}
